<script type="text/javascript" src="javascripts/jquery.js"></script>
<script type="text/javascript" src="javascripts/highcharts/highcharts.js"></script>
<script type="text/javascript" src="javascripts/highcharts/modules/exporting.js"></script>

<script>

var chart;
$(document).ready(function() {

   
	var chart = new Highcharts.Chart({
		
		chart: {
			renderTo: 'container',
			defaultSeriesType: 'column'
		},
		
		credits: {
			enabled: false
		},
		
		xAxis: {
			categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
		},
		
		title: {
			text: 'Proportion of <?=getNameFromId('item_groups','9')?> , <?=$year?>',
			style: { color: 'black', font: 'bold 13px Trebuchet MS, Verdana, sans-serif '}
		},

		plotOptions: {
						pie: {
							allowPointSelect: true,
							cursor: 'pointer',
							dataLabels: {
								enabled: true,
								formatter: function() {
									if (this.y > 5) return this.point.name;
								},
								color: 'black',
								style: {
									font: '11px Trebuchet MS, Verdana, sans-serif'
								}
							}
						}
					},
					
		series: [{
						type: 'pie',
						name: 'Browser share',
						data: [
<? foreach ($items as $item_id => $item_name) { ?>
							['<?=$item_name?>',   <?=getChildSumOfItemByState($item_id,'1',$year)?>],
<? } ?>
							/*{
								name: 'Chrome',    
								y: 12.8,
								sliced: false,
								selected: true
							}*/
						]
					}]

    
	}); 
   
});   



</script>

<body leftmargin="0" rightmargin="0" topmargin="0">
<!--application header-->
<? include "header.inc.php"; ?>
<!--EOapplication header-->
<!--left menu start-->
<? if ($USE_FRAME_MENU == false) { ?>
<div style="float: left; width:180px; height:100%; margin-right:20px;">
  <?
include "menu.php";
?>
</div>
<? } ?>
<!--left menu end-->

<div align="center">
<form action="?act=show_statistic" id="daftar" method="post" onSubmit="return GoSubmit(this)">
</form>

  <p>&nbsp;</p>

  <hr size="1" width="750">
  <table width="750" border="0" cellpadding="2" cellspacing="0" class="tableMainBodyFont">
    
    <tr>
      <td width="10" bgcolor="#CCCCCC">&nbsp;</td>
      <td bgcolor="#CCCCCC"><strong><?=getNameFromId('item_groups',$group_id);?></strong></td>
    </tr>
  </table>
  <br>
  <table width="600" border="1" class="tableMainBodyFont" id="datatable">
    <tr>
      <th width="200" align="center">State</th>
	  <? foreach ($items as $item_id => $item_name) {?>
	  <th width="100" align="center"><?=$item_name?></th>
	  <? } ?>
	  <th width="100" align="center">Total</th>
    </tr>
    <? foreach ($states as $state_id => $state_name) {?>
    <tr align="center">
      <td><?=$state_name?></td>
      
	  <? foreach ($items as $item_id => $item_name) {
			$v = getChildSumOfItemByState($item_id,$state_id,$year);
			$total_vertical[$item_id] += $v;
			$total_horizontal[$state_id] += $v;
	  ?>
	  <td><? echo ($v==0)? "-": number_format($v);?></td>
	  <? }
	  
	   ?>
	  <td><?=number_format($total_horizontal[$state_id])?></td>
    </tr>
    <? } ?>

    <tr align="center">
      <td><b>Malaysia</b></td>
	  <? foreach ($items as $item_id => $item_name) { ?>
      <td><b><?=number_format($total_vertical[$item_id])?></b></td>
	  <? } ?>
      <td><b><?=number_format(array_sum($total_vertical));?></b></td>
    </tr>
  </table>
  <p>&nbsp;</p>

<hr size="1" width="750">
<div id="container" style="width: 800px; height: 400px"></div>

</div>
</body>